<?php
	$options = $this->options;
	$optionsKey = array_keys($options);	
	$url = $this->windowParams["url"];
	$target = $this->windowParams["name"];
	$specs = $this->windowSpecs;
	$formId = $this->formId;
?>

<script>
	function <?php echo $options["id"] ?>_imgFind_click(){		
		//alert("open new window");
		var x = screen.width/2 - ( <?php echo $this->windowParams["specs"]["width"] /2 ?> );
		var y = screen.height/2 - ( <?php echo $this->windowParams["specs"]["height"] /2 ?> );
		var specs = "<?php echo $specs;?>";
		
		<?php if ($this->windowParams["specs"]["left"] == -1){ ?>
				specs = specs + "left=" + x;
		<?php } ?>
		
		<?php if ($this->windowParams["specs"]["top"] == -1){ ?>
				specs = specs + ",top=" + y;
		<?php } ?>
		
		
		<?php if ($this->beforePopupFunc != ""){
			//echo "<script>".$this->beforePopupFunc."()</script>";
			echo $this->beforePopupFunc ."()";
		}?>

		<?php if ($formId == ""){
			?> window.open("<?php echo $url . "&callback=". $this->callback ;?>","<?php echo $target;?>",specs).focus(); 
		<?php }else{
			?> window.open("","<?php echo $target;?>",specs).focus();
				$("#" + "<?php echo $formId?>").attr('target','<?php echo $target;?>');
				$("#" + "<?php echo $formId?>").attr('action','<?php echo $url . "&callback=". $this->callback;?>');
				$("#" + "<?php echo $formId?>").submit();
		<?php } ?>
		
				
		<?php if ($this->afterPopupFunc != ""){
			//echo "<script>".$this->beforePopupFunc."()</script>";
			echo $this->afterPopupFunc ."()";
		}?>		
	}	
</script>
<div style="display:inline">
	<input type="text"  readonly style="margin:0px;margin-right:2px;" onClick="<?php echo $options["id"] ?>_imgFind_click()"  
		<?php
			foreach($optionsKey as $key){
				echo $key . "=\"" .$options[$key] ."\" ";
			}
		?>
	 />
	<img class="imgBtn" style="margin:0px;" src="images/icon/ic_find.png" onClick="<?php echo $options["id"] ?>_imgFind_click()" />	
</div>